<template>
  <div>
    <el-form :model="form">
      <el-form-item label="姓名" :label-width="formLabelWidth">
        <el-input v-model="form.name" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="日期" :label-width="formLabelWidth">
        <!-- <el-input placeholder="请选择日期" v-model="form.datetime"> -->
        <el-date-picker
          v-model="form.datetime"
          type="datetime"
          placeholder="选择日期时间"
        >
        </el-date-picker>
        <!-- </el-input> -->
      </el-form-item>
      <el-form-item label="标题" :label-width="formLabelWidth">
        <el-input v-model="form.title" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="地址" :label-width="formLabelWidth">
        <el-input v-model="form.address" autocomplete="off"></el-input>
      </el-form-item>
    </el-form>
    <el-button type="success" @click="handleAdd">立即新增</el-button>
  </div>
</template>


<script>
import { mapMutations } from 'vuex'
export default {
  data() {
    return {
      form: {
        name: "",
        title: "",
        address: "",
        datetime: new Date(),
        id: new Date().getTime().toString()
      },
      formLabelWidth: "120px"
    };
  },
  methods: {
    ...mapMutations(['ADD_LIST']),
    handleAdd() {
      this.form.datetime = this.form.datetime.toLocaleString()
      this.ADD_LIST(this.form)
    }
  }
};
</script>